package com.manager.managersystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.manager.managersystem.entity.User;
import com.manager.managersystem.mapper.UserMapper;
import com.manager.managersystem.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author mao
 * @since 05-04
 */
@Service
@Transactional
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    /**
     * 通过用户名查找用户
     * @param username
     * @return
     */
    @Override
    public User findUserByUserName(String username) {
        QueryWrapper<User> wrapper = new QueryWrapper<User>();
        wrapper.eq("username",username);
        return baseMapper.selectOne(wrapper);
    }


    /**
     * 查询所有用户
     * @return
     */
    @Override
    public List<User> listAll() {
        return baseMapper.selectList(null);
    }
}
